package com.miyi.core;

import java.util.Properties;

import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;

public class VelocityHelper {  
	 private static final String encoding = "utf-8";
	 private VelocityEngine velocityEngine = null;
     private static class SingletonHolder {  
     	private static final VelocityHelper INSTANCE = new VelocityHelper();  
     }  

     private VelocityHelper (){
         Properties properties = new Properties();
         //properties.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "vm");
 		 properties.setProperty(Velocity.ENCODING_DEFAULT, encoding); 
 		 properties.setProperty(Velocity.INPUT_ENCODING, encoding); 
 		 properties.setProperty(Velocity.OUTPUT_ENCODING, encoding);
 		 
 		 properties.setProperty("parser.pool.size", "256");
         properties.setProperty("resource.loader", "class");
         properties.setProperty(
                 "class.resource.loader.class",
                 "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
         velocityEngine = new org.apache.velocity.app.VelocityEngine();
         velocityEngine.init(properties);
 		
     }
     public static final VelocityEngine getInstance() {  
         return SingletonHolder.INSTANCE.velocityEngine;  
     }  
}